package com.geping.etl.common.service.kettle;


import com.geping.etl.common.dto.KettleRunResultDto;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.List;

/***
 *  脚本执行转发器
 * @author liang.xu
 * @date 2021.06.25
 */
@Slf4j
public abstract  class RunPathServiceDispatcher {

    private static List<RunPathService> runPathServices=new ArrayList<>();


     public RunPathServiceDispatcher(){
         RunPathService  runPathService= (RunPathService) this;
         runPathServices.add(runPathService);
     }


    /**
     *
     * @param pathname
     * @return
     */
   public static KettleRunResultDto doRun(String pathname){
       for(RunPathService runPathService:runPathServices) {
           if (runPathService.canRun(pathname)) {
               return runPathService.runPath(pathname);
           }
       }
       return null;
   }
}